<?php
require 'phpmailer/PHPMailerAutoload.php';

$name       = @trim(stripslashes($_POST['name'])); 
$from       = @trim(stripslashes($_POST['email'])); 
$company       = @trim(stripslashes($_POST['company']));
$position       = @trim(stripslashes($_POST['position']));
$telephone       = @trim(stripslashes($_POST['telephone'])); 
$message    = @trim(stripslashes($_POST['message'])); 
$to   		= 'zaric@idevopscloud.com';
$subject = "【官网咨询】 - $name";
$html ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<table style="width:500px;border: 1px solid #8c8a8a;border-collapse: collapse;font-family: 微软雅黑, SimKai;">
<colgroup>
    <col width="10%">
    <col width="90%">
</colgroup>
<tr style="text-indent: 5px;border: 1px solid #8c8a8a;"><td style="border: 1px solid #8c8a8a;font-size: 13px;width:10%">姓名</td><td style="border: 1px solid #8c8a8a;font-size: 12px;width:90%">'.$name.'</td></tr>
<tr style="text-indent: 5px;border: 1px solid #8c8a8a;"><td style="border: 1px solid #8c8a8a;font-size: 13px;width:10%">公司</td><td style="border: 1px solid #8c8a8a;font-size: 12px;width:90%">'.$company.'</td></tr>
<tr style="text-indent: 5px;border: 1px solid #8c8a8a;"><td style="border: 1px solid #8c8a8a;font-size: 13px;width:10%">职位</td><td style="border: 1px solid #8c8a8a;font-size: 12px;width:90%">'.$position.'</td></tr>
<tr style="text-indent: 5px;border: 1px solid #8c8a8a;"><td style="border: 1px solid #8c8a8a;font-size: 13px;width:10%">电话</td><td style="border: 1px solid #8c8a8a;font-size: 12px;width:90%">'.$telephone.'</td></tr>
<tr style="text-indent: 5px;border: 1px solid #8c8a8a;"><td style="border: 1px solid #8c8a8a;font-size: 13px;width:10%">邮箱</td><td style="border: 1px solid #8c8a8a;font-size: 12px;width:90%">'.$from.'</td></tr>
<tr style="text-indent: 5px;border: 1px solid #8c8a8a;"><td style="border: 1px solid #8c8a8a;font-size: 13px">留言:</td><td style="border: 1px solid #8c8a8a;font-size: 12px">
<pre style="display:table;table-layout:fixed;width: 90%;font-size: 12px;">'.$message.'</pre></td></tr>
</table></html>';

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->SMTPDebug = 1;	
$mail->Host = 'smtp.exmail.qq.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'service@idevopscloud.com';                 // SMTP username
//$mail->Password = 'Service123com';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                    // TCP port to connect to
$mail->AddReplyTo($from, $name);

$mail->setFrom('service@idevopscloud.com', '客服');
//$mail->addAddress('allen@idevopscloud.com');               // Name is optional
$mail->addAddress('zaric@idevopscloud.com');               // Name is optional
//$mail->addCC('admin@idevopscloud.com');

$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = $subject;
$mail->Body    = $html;

if(!$mail->send()) {
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Done';
}
